﻿using System;
using System.Collections.Generic;
using System.Text;

namespace KingOfCSharp.iHunter.Plugins.BayesianFilter
{
    class BayesianFilterProvider : IFilterProvider
    {
        private System.Data.DataSet dataSet;

        #region IPlugin Members

        public Guid Guid
        {
            get
            {
                return new Guid("3B07E46D-484C-42e7-922C-E5101D0FD631");
            }
        }

        public string Name
        {
            get { return "Bayesian Filter"; }
        }

        public string Description
        {
            get { return "This is a Bayesian filter to avoid spams"; }
        }

        public void Initialize(IPluginClient client)
        {
            //this.dataSet = new System.Data.DataSet();
            this.dataSet = client.GetPluginDatabase();
            if (this.dataSet == null)
            {
                this.dataSet = new System.Data.DataSet();
            }
        }

        public System.Windows.Forms.UserControl GetPluginConfigureEditor()
        {
            return new FilterConfigureControl();
        }

        public event PluginErrorEventHandler ErrorOccur;

        #endregion

        #region IDisposable Members

        public void Dispose()
        {
            // Do nothing
        }

        #endregion

        #region IFilterProvider Members

        public IFilter CreateFilterInstance(FilterInfo info)
        {
            IFilter filter = null;
            try
            {
                filter = new BayesianFilter(info.Settings);
            }
            catch
            {
                return null;
            }
            return filter;
        }

        public System.Windows.Forms.UserControl GetFilterConfigureEditor()
        {
            return new FilterConfigureControl();
        }

        public System.Windows.Forms.UserControl[] GetNewFilterWizardPages()
        {
            return new System.Windows.Forms.UserControl[1] { new FilterConfigureControl() };
        }

        #endregion

        #region IPlugin Members


        System.Windows.Forms.UserControl IPlugin.GetPluginConfigureEditor()
        {
            return null;
        }

        #endregion
    }
}
